Skip to content

Conversation

@jablko
Copy link
Contributor

@jablko jablko commented Apr 21, 2022

Can we remove semver.ts, and instead use the standard semver npm package, which is similar?

semver.ts doesn't handle some valid cases, e.g. andrewbranch/definitely-not-slow@d9d0828#diff-02cbc9970890cd33cf15c9ffb2f983aa63db1d290949662f06c134dad8fc9270R192 whereas switching to the standard package allows versions to be parsed consistently.

@andrewbranch
Copy link
Member

Yes please, this would be great. If you fix the build error I’ll do a quick check and get this in. Thanks!

const firstTypedVersion = min(
mapDefined(versions, ({ hasTypes, version }) => (hasTypes ? version : undefined)),
(a, b) => b.greaterThan(a)
semver.compare
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Use semver.compare().

Comment on lines -17 to -18
(info.versions.has(notNeeded.versionString) &&
!assertDefined(info.versions.get(notNeeded.versionString)).deprecated)
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

!isAlreadyDeprecated() ensures notNeeded is either < latest or not deprecated.

}
const needsPublish = canPublish && pkg.contentHash !== latestVersionInfo.typesPublisherContentHash;
const patch = needsPublish
? latestVersion!.minor === pkg.minor
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

latestPatchMatchingMajorAndMinor() ensures latestVersion.minor === pkg.minor.

});
return best(versionsWithTypings, (a, b) => a > b);
): string | null {
return semver.maxSatisfying([...versions.keys()], `~${major}.${minor}`);
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I replaced latestPatchMatchingMajorAndMinor() with the equivalent semver.maxSatisfying(..., `~${major}.${minor}`)

@jablko jablko force-pushed the patch-37 branch 2 times, most recently from 1b99e76 to 53072ff Compare April 21, 2022 17:02
@jablko
Copy link
Contributor Author

jablko commented Apr 21, 2022

  • Thank you! I've fixed the build error.

@andrewbranch
Copy link
Member

@sandersn any objections?

@andrewbranch andrewbranch merged commit 575fd10 into microsoft:master Apr 21, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants